package com.news.controller;

import com.news.common.lang.Result;
import com.news.entity.SysNews;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class NewsController extends BaseController{

    @GetMapping("/newsList")
    public Result list(SysNews sysNews){
        List<SysNews> newsList=sysNewsService.list();
        return Result.succ(newsList);
    }

    @GetMapping("/news/{id}")
    public Result detail(@PathVariable(name = "id") Long id){
        SysNews news=sysNewsService.getById(id);
        Assert.notNull(news,"该文章已被删除");
        return Result.succ(news);
    }
}
